from django.shortcuts import render_to_response
from webutils import SessionUtils
from django.views.decorators.cache import never_cache
#from compiler.pycodegen import EXCEPT

class AuthenticationFitler(object):

    def __init__(self, f):
        self.f = f
        
    @never_cache
    def __call__(self, request):
        flag = SessionUtils(request).getAttribute('flag')
        if flag <> None:
            return self.f(request)
        else:
            return render_to_response('common/redirect.html', {'uri':'/login'})
